#include "label.h"
#include <QDebug>

int Label::_Delta = 0;

Label::Label(QWidget* parent)
    :QLabel(parent)
{

}

void Label::enterEvent(QEvent *event)
{
    (void) event;
    qDebug() << "进入label";
}

void Label::leaveEvent(QEvent *event)
{
    (void) event;
    qDebug() << "离开label";
}

// 鼠标按下 并不仅仅是左键按下会触发，右键按下也会触发，中间键按下同样会触发
void Label::mousePressEvent(QMouseEvent *event)
{
    (void)event;
//    qDebug() << "鼠标按下";
    qDebug() << "x = "<< event->x() << "y = " << event->y();
    if(event->button() == Qt::LeftButton)
    {
        qDebug() << "鼠标左键按下";
    }
    else if(event->button() == Qt::RightButton)
    {
         qDebug() << "鼠标右键按下";
    }
    else if(event->button() == Qt::MidButton)
    {
         qDebug() << "鼠标滑轮键按下";
    }
}


void Label::mouseMoveEvent(QMouseEvent *event)
{
    qDebug() << "x = "<< event->x() << "y = " << event->y();
}

void Label::wheelEvent(QWheelEvent *event)
{

    qDebug() << event->angleDelta();
    // 计算滑轮总共滑了多少距离
    _Delta += event->angleDelta().ry();
    qDebug() << _Delta;
}

void Label::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        qDebug() << "左键释放";
    }
    else if(event->button() == Qt::RightButton)
    {
        qDebug() << "右键释放";
    }
    else if(event->button() == Qt::MidButton)
    {
        qDebug() << "滑轮释放";
    }

}

void Label::mouseDoubleClickEvent(QMouseEvent *event)
{
    if(event->button() == Qt::LeftButton)
    {
        qDebug() << "左键双击";
    }
    else if(event->button() == Qt::RightButton)
    {
        qDebug() << "右键双击";
    }
}


